package com.ruiyian.bridge.project.service.impl;

import com.ruiyian.bridge.project.domain.DeviceType;
import com.ruiyian.bridge.project.mapper.DeviceTypeMapper;
import com.ruiyian.bridge.project.service.DeviceTypeService;
import com.ruiyian.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 传感器类型Service业务层处理
 *
 * @author ruiyian
 * @date 2022-01-20
 */
@Service
public class DeviceTypeServiceImpl implements DeviceTypeService
{
    @Autowired
    private DeviceTypeMapper deviceTypeMapper;

    /**
     * 查询传感器类型
     *
     * @param id 传感器类型主键
     * @return 传感器类型
     */
    @Override
    public DeviceType selectTSensorTypeById(Long id)
    {
        return deviceTypeMapper.selectTSensorTypeById(id);
    }

    /**
     * 查询传感器类型列表
     *
     * @param deviceType 传感器类型
     * @return 传感器类型
     */
    @Override
    public List<DeviceType> selectTSensorTypeList(DeviceType deviceType)
    {
        return deviceTypeMapper.selectTSensorTypeList(deviceType);
    }

    /**
     * 新增传感器类型
     *
     * @param deviceType 传感器类型
     * @return 结果
     */
    @Override
    public int insertTSensorType(DeviceType deviceType)
    {
        deviceType.setCreateTime(DateUtils.getNowDate());
        return deviceTypeMapper.insertTSensorType(deviceType);
    }

    /**
     * 修改传感器类型
     *
     * @param deviceType 传感器类型
     * @return 结果
     */
    @Override
    public int updateTSensorType(DeviceType deviceType)
    {
        return deviceTypeMapper.updateTSensorType(deviceType);
    }

    /**
     * 批量删除传感器类型
     *
     * @param ids 需要删除的传感器类型主键
     * @return 结果
     */
    @Override
    public int deleteTSensorTypeByIds(Long[] ids)
    {
        return deviceTypeMapper.deleteTSensorTypeByIds(ids);
    }

    /**
     * 删除传感器类型信息
     *
     * @param id 传感器类型主键
     * @return 结果
     */
    @Override
    public int deleteTSensorTypeById(Long id)
    {
        return deviceTypeMapper.deleteTSensorTypeById(id);
    }

    @Override
    public DeviceType getByType(String type) {
        return deviceTypeMapper.getByType(type);
    }
}
